package com.blue.Impl.workflow;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.blue.common.constant.CommonConstant;
import com.blue.service.workflow.IBusinessDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.blue.mapper.workflow.BusinessDataMapper;
import com.blue.po.workflow.BusinessDataPO;
import org.springframework.util.CollectionUtils;

import java.util.List;


@Service
public class BusinessDataServiceImpl extends ServiceImpl<BusinessDataMapper, BusinessDataPO> implements IBusinessDataService {

    @Override
    public Object getData(String instanceId) {
        List<BusinessDataPO> businessDataPOS = this.list(new LambdaQueryWrapper<BusinessDataPO>()
                .eq(BusinessDataPO::getInstanceId, instanceId)
                .eq(BusinessDataPO::getDisplayFlag, CommonConstant.YES));
        if (CollectionUtils.isEmpty(businessDataPOS)) {
            return null;
        }
        return JSON.parseObject(businessDataPOS.get(0).getBusinessData(), Object.class);
    }
}
